/*
 * @Description: 城市选择控制器
 * @Author: iamsmiling
 * @Date: 2021-06-08 08:41:31
 * @LastEditTime: 2021-06-09 14:45:10
 */
import 'package:credit_business_circle/domain/local/city/city_model.dart';
import 'package:get/get.dart';

class CitySelectController extends GetxController {
  // List<CityModel> cityList = [];
  int currentCityId = 0;
  List<CityGrounpEntity> groups = [
    CityGrounpEntity(tag: "热门城市", list: [
      CityEntity(name: "北京", id: 0),
      CityEntity(name: "上海"),
      CityEntity(name: "广州"),
      CityEntity(name: "深圳"),
      CityEntity(name: "成都"),
      CityEntity(name: "南京"),
      CityEntity(name: "重庆"),
      CityEntity(name: "天津"),
      CityEntity(name: "武汉"),
    ]),
    CityGrounpEntity(tag: "A", list: [
      CityEntity(name: "鞍山"),
      CityEntity(name: "阿拉善"),
      CityEntity(name: "安康"),
      CityEntity(name: "阿克苏"),
      CityEntity(name: "阿勒泰"),
      CityEntity(name: "阿拉尔"),
      CityEntity(name: "安阳"),
      CityEntity(name: "安庆"),
      CityEntity(name: "武汉"),
      CityEntity(name: "安阳"),
      CityEntity(name: "安顺"),
      CityEntity(name: "阿里"),
      CityEntity(name: "澳门"),
    ]),
    CityGrounpEntity(tag: "B", list: [
      CityEntity(name: "北京"),
      CityEntity(name: "巴黎"),
    ]),
    CityGrounpEntity(tag: "D", list: [
      CityEntity(name: "鞍山"),
      CityEntity(name: "阿拉善"),
      CityEntity(name: "安康"),
      CityEntity(name: "阿克苏"),
      CityEntity(name: "阿勒泰"),
      CityEntity(name: "阿拉尔"),
      CityEntity(name: "安阳"),
      CityEntity(name: "安庆"),
      CityEntity(name: "武汉"),
      CityEntity(name: "安阳"),
      CityEntity(name: "安顺"),
      CityEntity(name: "阿里"),
      CityEntity(name: "澳门"),
    ]),
    CityGrounpEntity(tag: "C", list: [
      CityEntity(name: "鞍山"),
      CityEntity(name: "阿拉善"),
      CityEntity(name: "安康"),
      CityEntity(name: "阿克苏"),
      CityEntity(name: "阿勒泰"),
      CityEntity(name: "阿拉尔"),
      CityEntity(name: "安阳"),
      CityEntity(name: "安庆"),
      CityEntity(name: "武汉"),
      CityEntity(name: "安阳"),
      CityEntity(name: "安顺"),
      CityEntity(name: "阿里"),
      CityEntity(name: "澳门"),
    ]),
  ];
  @override
  void onInit() {
    super.onInit();
    //加载城市列表
    // rootBundle.loadString('assets/data/city.json').then((value) {
    //   cityList.clear();
    //   Map countyMap = json.decode(value);
    //   List list = countyMap['china'];
    //   list.forEach((v) {
    //     cityList.add(CityModel.fromJson(v));
    //   });
    //   _handleList(cityList);
    // });
  }

  // void _handleList(List<CityModel> list) {
  //   if (list.isEmpty) return;
  //   for (int i = 0, length = list.length; i < length; i++) {
  //     String pinyin = PinyinHelper.getPinyinE(list[i].name);
  //     String tag = pinyin.substring(0, 1).toUpperCase();
  //     list[i].namePinyin = pinyin;
  //     if (RegExp('[A-Z]').hasMatch(tag)) {
  //       list[i].tagIndex = tag;
  //     } else {
  //       list[i].tagIndex = '#';
  //     }
  //   }
  //   // A-Z sort.
  //   SuspensionUtil.sortListBySuspensionTag(list);

  //   // show sus tag.
  //   SuspensionUtil.setShowSuspensionStatus(cityList);

  //   // add header.
  //   cityList.insert(
  //       0,
  //       CityModel(
  //           name: 'header', tagIndex: "#")); //index bar support local images.
  // }
}
